package com.lych.server.service;

import com.lych.dubbo.api.UserApi;
import com.lych.model.domain.User;
import com.lych.model.vo.HuanXinUserVo;
import com.lych.server.interceptor.UserHolder;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class HuanxinService {

    @DubboReference
    private UserApi userApi;

    /**
     * 查询当前用户环信账号
     * @return
     */
    public HuanXinUserVo findHuanXinUser() {
        //得到用户id
        Long userId = UserHolder.getUserId();
        //通过userid查询信息
        User user = userApi.findById(userId);
        //非空判断
        if (user == null){
            return null;
        }
        return new HuanXinUserVo(user.getHxUser(),user.getHxPassword());
    }
}
